import * as fs from "node:fs";
import { formatXml, KXMLDocument } from "../k-xml.js";

export default function test(file:string){
    const doc:KXMLDocument = {
        header: {
            version: "1.0",
            encoding: "UTF-8"
        },
        dtd: {
            rootTagName: "map"
        },
        rootTag: {
            name: "map",
            attributes: [
                ["version","1.10"],
                ["tiledversion","1.11.0"],
                ["orientation","isometric"],
                ["renderorder","right-down"],
                ["width","30"],
                ["height","20"],
                ["tilewidth","64"],
                ["tileheight","48"],
                ["infinite","0"],
                ["nextlayerid","3"],
                ["nextobjectid","2"]
            ],
            type: "2-side",
            children: [
                {
                    name: "tileset",
                    attributes: [
                        ["firstgid","1"],
                        ["source","testcg.tsx"]
                    ],
                    type: "single"
                },
                {
                    name: "layer",
                    attributes: [
                        ["id","1"],
                        ["name","Tile Layer 1"],
                        ["width","30"],
                        ["height","20"],
                    ],
                    type: "2-side",
                    children: [
                        {
                            name: "data",
                            attributes: [
                                ["encoding","csv"]
                            ],
                            type: "2-side",
                            children: [
`0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,3,6,6,6,6,6,6,6,6,6,9,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,2,5,5,5,5,5,5,5,5,5,8,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,2,5,5,5,5,5,5,5,5,5,8,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,2,5,5,5,5,5,5,5,5,5,8,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,2,5,5,5,5,5,5,5,5,5,8,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,1,4,4,4,4,4,4,4,4,4,7,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0`
                            ]
                        }
                    ]
                },
                {
                    name: "objectgroup",
                    attributes: [
                        ["id","2"],
                        ["name","Object Layer 1"]
                    ],
                    type: "2-side",
                    children: [
                        {
                            name: "object",
                            attributes: [
                                ["id","1"],
                                ["gid","10"],
                                ["x","794.25"],
                                ["y","672.094"],
                                ["width","372"],
                                ["height","473"]
                            ],
                            type: "single"
                        }
                    ]
                }
            ]
        }
    };
    fs.writeFileSync(file,formatXml(doc,"  "),"utf8");
}
